package com.sparrow.socket.http.bean;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Http方法定义
 */
public class HttpMethodWrapper {
    private final Object bean;
    private final Method method;

    public HttpMethodWrapper(Object bean, Method method) {
        this.bean = bean;
        this.method = method;
    }

    public Object getBean() {
        return bean;
    }

    public Method getMethod() {
        return method;
    }

    public Object invoke(Object... arg) {
        try {
            return method.invoke(bean, arg);
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }
}
